//
//  AppDelegate.swift
//  NewWeiBo
//
//  Created by 吴天益 on 2017/7/22.
//  Copyright © 2017年 ttt. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    let tabBar: TTTabBarController = TTTabBarController()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        //实例化window
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.backgroundColor = UIColor.white
        
        window?.rootViewController = tabBar
        
        window?.makeKeyAndVisible()
        
        //注册通知
        NotificationCenter.default.addObserver(self, selector: #selector(changeRootViewController(noti:)), name: NSNotification.Name(rawValue: switchWindowRootController), object: nil)
        
        return true
    }
    
    //MARK: - 通知方法实现
    func changeRootViewController(noti: Notification){
        
        //判断两个类是否相同
        if noti.object != nil{
            
            window?.rootViewController = TTWelcomeViewController()
        }else{
            
            window?.rootViewController = TTTabBarController()
        }
        
        
        
    }
    
    deinit {
        NotificationCenter.default.removeObserver(self)
    }

}


    
    
    
    
    
    
    


